$OpenBSD: patch-server_getmac_c,v 1.2 2013/11/26 09:39:41 jca Exp $
--- server/getmac.c.orig	Thu Sep 11 03:27:06 1997
+++ server/getmac.c	Tue Nov 26 00:40:06 2013
@@ -50,10 +50,15 @@ static char rcsid[] =
 #include <net/if_var.h>
 #endif
 #endif
+#if defined(__OpenBSD__)
+#include <net/if_var.h>
+#endif
 
 #include <netinet/in.h>
+#define _KERNEL
 #include <netinet/in_var.h>
 #include <netinet/if_ether.h>
+#undef _KERNEL
 #include <arpa/inet.h>
 
 /* Cast a struct sockaddr to a sockaddr_in */
@@ -85,14 +90,20 @@ getmac(ifname, result)
     struct in_ifaddr in;
   } ifaddr;
   u_long addr = 0;
+#if defined(__OpenBSD__)
+#else
   char name[16];
   char fullname[16];
+#endif
   static kvm_t *kd = NULL;
 
   bzero(&arpcom, sizeof(arpcom));
   bzero(&ifaddr, sizeof(ifaddr));
+#if defined(__OpenBSD__)
+#else
   bzero(name, sizeof(name));
   bzero(fullname, sizeof(fullname));
+#endif
 
   /* Open kernel memory for reading */
   kd = kvm_open(0, 0, 0, O_RDONLY, "kvm_open");
@@ -110,7 +121,7 @@ getmac(ifname, result)
 
   ac = &arpcom;
   ifp = &arpcom.ac_if;
-#if defined(__bsdi__) || defined(__FreeBSD__)
+#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   ep = arpcom.ac_enaddr;
 #else
   ep = arpcom.ac_enaddr.ether_addr_octet;
@@ -124,7 +135,11 @@ getmac(ifname, result)
     kvm_close(kd);
     return(-1);
   }
+#if defined(__OpenBSD__)
+  for ( ; addr; addr = (u_long)ifp->if_list.tqe_next) {
+#else
   for ( ; addr; addr = (u_long)ifp->if_next) {
+#endif
     if (kvm_read(kd, addr, (char *)ac, sizeof(*ac)) != sizeof(*ac)) {
       syslog(LOG_ERR, "kvm_read() error in getmac(): %m");
       kvm_close(kd);
@@ -135,6 +150,10 @@ getmac(ifname, result)
       continue;
 
     /* Only look at the specified interface */
+#if defined(__OpenBSD__)
+    if (strcmp(ifp->if_xname, ifname) != 0)
+      continue;
+#else
     if (kvm_read(kd, (u_long)ifp->if_name, (char *)name, sizeof(name)) !=
                  sizeof(name)) {
       syslog(LOG_ERR, "kvm_read() error in getmac(): %m");
@@ -145,6 +164,7 @@ getmac(ifname, result)
     sprintf(fullname, "%s%d", name, ifp->if_unit);
     if (strcmp(fullname, ifname) != 0)
       continue;
+#endif
 
     kvm_close(kd);
     bcopy(ep, result, 6);
